<template>
  <div>
    <el-table :data="tableData" :show-header="false" style="width: 100%;margin-top: 15px;" height="60" :header-cell-style="headerCellStyle" :cell-style="cellStyle">
      <template slot="empty">
        <p>暂无推屏</p>
      </template>
      <el-table-column prop="id" align="center" label="序号" min-width="10%">
      </el-table-column>
      <el-table-column prop="content" :show-overflow-tooltip="true" align="center" label="跑马灯消息" min-width="70%">
      </el-table-column>
      <el-table-column prop="statusVal" :show-overflow-tooltip="true" align="center" label="状态" min-width="10%">
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="10%">
        <template slot-scope="scope">
          <el-button v-if="scope.row.status==41 && scope.row.downTime>0" type="text" size="mini" disabled>{{scope.row.downTime}}s</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  export default {
    name: "liveControllerMarqueePushScreen",
    components: {
    },
    props:{
      data:{
        type: Object,
        default:()=>{}
      }
    },
    data() {
      return {
        parentData:{},
        headerCellStyle:{
          'background-color': '#f1f1f1',
          'font-size':'12px',
          'color':'#000000'
        },
        cellStyle:{
          'font-size':'12px',
          'border-bottom':'0'
        },
        tableData:[],
      }
    },
    mounted: function () {
      this.parentData = this.data;
      this.findPage();
      this.init();
    },
    destroyed(){ // 页面销毁
      this.clearTimer()
    },
    methods: {
      clearTimer(){ // 清除定时器
        clearInterval(this.timer)
      },
      init() {
        this.timer = setInterval(() => {
          if(this.tableData!=null && this.tableData.length>0){
            this.tableData.forEach((item,idx) => {
              if(item.status==41 && item.downTime<=0){
                this.findPage();
              }
              item.downTime--;
            })
          }
        },1000)
      },
      findPage(){
        this.tableData = []
        let findDataForm = {
          liveId:this.parentData.id
        }
        this.utils.request.liveRequest({
          url: '/api/v1/liveLanternInfo/getPushLiveLanternInfo',
          method: 'get',
          params: findDataForm
        }).then(result => {
          let data = result.data;
          if (data && data.code === '0') {
            this.tableData = []
            if(data.data){
              this.tableData.push(data.data);
            }
          }
        })
      },
      pushScreen(row){
        this.findPage();
      },
      offPushScreen(row){
        this.$emit("pushScreenHandle",row)
      }
    }
  }
</script>
<style scoped lang="scss">

</style>
